<?php
class Model_Task
{
    private $_id;

    private $_name;

    private $_discription;

    private $_dateStart;

    private $_dateEnd;

    private $_cost;

    private $_bonus;

    private $_penlty;

    public function __construct(
        $id, $name, $discription,
        $dateStart, $dateEnd, $cost,
        $bonus, $penalty
    )
    {
        $this->_id = $id;
        $this->_name = $name;
        $this->_discription = $discription;
        $this->_dateStart = $dateStart;
        $this->_dateEnd = $dateEnd;
        $this->_cost = $cost;
        $this->_bonus = $bonus;
        $this->_penlty = $penalty;
    }

    static public function findById($id)
    {
        $db = Zend_Db_Table::getDefaultAdapter();
        $select = $db->select();
        $select->from('task')
            ->where('id = ?', $id);
        if ($row = $select->query()->fetch()) {
            $task = new self(
                $row['id'], $row['name'], $row['discription'],
                $row['dateStart'], $row['dateEnd'], $row['cost'],
                $row['bonus'], $row['penalty']
            );
            return $task;
        }

        return false;
    }
}